<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="set">设置loc</div>
<div id="get">获取loc</div>
显示: <span id="msg"></span>
<script>
    var set = document.getElementById('set');
    var get = document.getElementById('get');
    var msg = document.getElementById('msg');

    var util = (function () {
        var prefix = 'h5'

        var setStorage = function (key,val) {
            localStorage.setItem(prefix+key,val)

        }
        var getStorage = function (key) {
            return localStorage.getItem(prefix+key)
        }

        return {
            setStorage:setStorage,
            getStorage:getStorage

        }

    })()

    set.onclick = function () {
       util.setStorage('xmg','111111')

    }

    get.onclick = function () {
        var ss = util.getStorage('xmg')
        msg.innerHTML = ss
    }

</script>

</body>
</html>